package com.breaktian.share;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

public class ShareEntity implements Parcelable{

    public String title;
    public String content;
    public String url;
    public String imagePath;

    public String imageUrl;

    public ShareEntity() {
    }

    public ShareEntity(String title, String content, String url, String imageUrl) {
        this.title = title;
        this.content = content;
        this.url = url;
        this.imageUrl = imageUrl;
    }

    protected ShareEntity(Parcel in) {
        this.title = in.readString();
        this.content = in.readString();
        this.url = in.readString();
        this.imagePath = in.readString();
        this.imageUrl = in.readString();
    }

    /**
     * 是否是图片分享
     * */
    public boolean isImageShare(){
        return TextUtils.isEmpty(title)&& TextUtils.isEmpty(content)&&TextUtils.isEmpty(url)&&(!TextUtils.isEmpty(imageUrl)||!TextUtils.isEmpty(imagePath));
    }

    ShareEntity duplicate() {
        ShareEntity entry = new ShareEntity(title, content, url, imageUrl);
        entry.imagePath = imagePath;
        return entry;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.title);
        dest.writeString(this.content);
        dest.writeString(this.url);
        dest.writeString(this.imagePath);
        dest.writeString(this.imageUrl);
    }

    public static final Creator<ShareEntity> CREATOR = new Creator<ShareEntity>() {
        @Override
        public ShareEntity createFromParcel(Parcel source) {
            return new ShareEntity(source);
        }

        @Override
        public ShareEntity[] newArray(int size) {
            return new ShareEntity[size];
        }
    };
}
